import { Controller, Get, HttpStatus, Param, Post, Res } from '@nestjs/common';
import { Response } from 'express';

const s = {
  Id: '111',
  Name: 'xxx',
};

@Controller('catscreate')
export class CatsController {
  @Post()
  create(@Res() res: Response) {
    res.status(HttpStatus.CREATED).send(s);
  }

  @Get(':id')
  findAll(@Res({ passthrough: true }) res: Response, @Param('id') id: string) {
    console.log('id', id);
    if (!id) {
      res.status(HttpStatus.OK).json('id is Error');
      return;
    }
    res.status(HttpStatus.OK).json([
      { Id: '111', Name: 'xxx' },
      { Id: '222', Name: 'aaa' },
      { Id: '333', Name: 'ccc' },
    ]);
  }
}
